<template>
    <div>
<table class="table">
    <tbody>
    <tr>
        <td>用户名</td>
        <td><input type="text" v-model="data.name"></td>
    </tr>
       <tr>
        <td>密码</td>
        <td><input type="password" v-model="data.pwd"></td>
    </tr>
       <tr>
        <td></td>
        <td><input type="button" class="btn btn-success" value="登录" @click="Deng"></td>
    </tr>
    </tbody>
    
</table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';
import { useStore } from '@/stores/user';
const pina=useStore()
const router=useRouter()

const data=ref({
    name:"",
    pwd:""
})

const Deng=()=>{
    axios.get("/api/User/Login",{params:data.value}).then(res=>{
        if(res.data.id==-1)                                    
        {
            alert("用户名不存在")
        }
        else if(res.data.id==-2)
        {
            alert("密码错误")
        }
        else
        {
            alert("登录成功")
            pina.userinfor=res.data;
            router.push("/Show");
        }
    })
}












</script>

<style scoped>

</style>